package com.example.service;
import com.example.exception.ConcurrencyFailException;
import java.util.function.Consumer;
import java.util.function.Supplier;

/*
@description:
@ClassName DbConcurrencySafe
@author chen
@create 2025-06-11 17:10
@Version 1.0
*/
public interface DbConcurrencySafe
{

    <T> T exec(String key, Supplier<T> callback, Consumer<T> successCallBack, Consumer<ConcurrencyFailException> failCallBack);



    default <T> T exec(Class<?> po, String id, Supplier<T> callback)
    {
        return exec(String.format("%s:%s", po.getName(), id), callback, null, null);
    }
}
